{% extends "layout.html" %}

{% block title %}foursquare-latitude: Nearby{% endblock title %}
{% block main %}

  <h2>Latest</h2>
  <ul>
    <li>Latitude: Last seen at {{ location.latitude }}, {{ location.longitude }} ({{ location.timestampMs }})
    <li>Foursquare: Last seen at {{ checkin.venue.name }} ({{ checkin.created }})
  </ul>

  <h2>Matches</h2>
  <table width="100%">
    <tr>
      <td><h3>Venue</h3></td>
      <td><h3>Place</h3></td>
    </tr>
    {% for row in matches %}
    <tr>
      <td>
	<h3>
        <a href="http://foursquare.com/venue/{{ row.0.id }}">
          {% if row.0.primarycategory.iconurl %}
          <img src="{{ row.0.primarycategory.iconurl }}" height="30" width="30" />
          {% else %}
          <img src="http://foursquare.com/img/categories/building/default.png" height="30" width="30" />
          {% endif %}
          <a href="http://foursquare.com/row.0/{{ row.0.id }}">{{ row.0.name }}</a>
        </h3>
        <dl>
          <dt>id</dt><dd>{{ row.0.id }}</dd>
          <dt>name</dt><dd>{{ row.0.name }}</dd>
          <dt>address</dt><dd>{{ row.0.address }} {{ row.0.city }}, {{ row.0.state }} {{ row.0.zip }}</dd>
          <dt>phone</dt><dd>{{ row.0.phone }}</dd>
          <dt>geolat</dt><dd>{{ row.0.geolat }}</dd>
          <dt>geolong</dt><dd>{{ row.0.geolong }}</dd>
        </dl>
      </td>

      {% if row.1 %}
      <td>
	<h3>
        <a href="{{ row.1.url }}">
          {% if row.1.icon %}
          <img src="{{ row.1.icon }}" height="30" width="30" />
          {% else %}
          <img src="http://foursquare.com/img/categories/building/default.png" height="30" width="30" />
          {% endif %}
        </a>
        <a href="{{ row.1.url }}">{{ row.1.name }}</a>
        </h3>
        <dl>
          <dt>id</dt><dd>{{ row.1.id }}</dd>
          <dt>name</dt><dd>{{ row.1.name }}</dd>
          <dt>formatted_address</dt><dd>{{ row.1.formatted_address }}</dd>
          <dt>phone</dt><dd>{{ row.1.formatted_phone_number }}</dd>
          <dt>geolat</dt><dd>{{ row.1.geometry.location.lat }}</dd>
          <dt>geolong</dt><dd>{{ row.1.geometry.location.lng }}</dd>
        </dl>
      </td>
      {% endif %}
    </tr>
    {% endfor %}
  </table>

  <h2>Buzzes</h2>
  <ul>
  {% for buzz in buzzes %}
    <li>
      <a href="{{ buzz.links.alternate.0.href }}">{{ buzz.title }}</a>
    </li>
  {% endfor %}
  </ul>

  <h2>Venues</h2>
  {% for group in venues.groups %}
  <h3>{{ group.type }}</h3>
  <ul>
    {% for venue in group.venues %}
    <li>
      <a href="http://foursquare.com/venue/{{ venue.id }}">
      {% if venue.primarycategory.iconurl %}
        <img src="{{ venue.primarycategory.iconurl }}" />
      {% else %}
        <img src="http://foursquare.com/img/categories/building/default.png" />
      {% endif %}
      </a>
      <a href="http://foursquare.com/venue/{{ venue.id }}">{{ venue.name }}</a>
      (<a href="/foursquare?OP=checkin&vid={{ venue.id }}&geolat={{ location.latitude }}&geolong={{ location.longitude }}">checkin</a>)
    </li>
    {% endfor %}
  </ul>
  {% endfor %}

  <h2>Places</h2>
  <ul>
  {% for place in places %}
    <li>
      {% if place.icon %}
        <img src="{{ place.icon }}" />
      {% else %}
        <img src="http://foursquare.com/img/categories/building/default.png" />
      {% endif %}
      <a href="{{ place.url }}">{{ place.name }}</a>
    </li>
  {% endfor %}
  </ul>
  <h3>Attributions</h3>
  {% for html_attribution in html_attributions %}
    <li>{{ html_attribution}}</li>
  {% endfor %}

<script src="static/js/main.js"></script>

{% endblock main %}

{% block sidebar_content %}
{% endblock sidebar_content %}


{% block bottom_block %}
{% endblock bottom_block %}
